package com.apartment.sevice.impl;

import com.apartment.dao.OrderDao;
import com.apartment.data.entity.Indent;
import com.apartment.data.view.Indentview;
import com.apartment.sevice.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Author : xuzhiyong
 * Date : 2022/5/27 17:52
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderDao orderDao;
    @Override
    public List<Indent> findAllIndent() {
        return orderDao.findAll();
    }

    @Override
    public boolean addIndent(Indent indent) {
        boolean flag = false;
        try {
            orderDao.save(indent);
            flag = true;
        }catch (Exception e){
            System.out.println("");
            e.printStackTrace();
        }
        return flag;
    }

    @Override
    public boolean deleteIndentById(Integer id) {
        boolean flag = false;
        try {
            orderDao.deleteById(id);
            flag = true;
        }catch (Exception e){
            System.out.println("删除失败");
            e.printStackTrace();
        }
        return flag;
    }

    @Override
    public List<Indent> findIndentsByUserId(Integer id) {
        return orderDao.findIndentsByUserId(id);
    }

    @Override
    public List<Indent> findIndentByUserId(Integer id){
        return orderDao.findIndentByUserId(id);
    }


}
